<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //   语法 /xxx/  内容中间不能加变量 ，只能加字符串中的内容，除非用eval(` `),
          //将字符串转换为js程序
        let tw="saqwd520";
        //是否有数字520
        console.log(/520/.test(tw));//true

        let a="520";
        console.log(eval(`/${a}/`).test(tw));//true
    </script>
</body>
</html>